<div id="toolbar-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <div id="toolbar" class="toolbar">
      <table class="toolbar">
        <tbody>
          <tr>
            <td id="toolbar-unpublish" class="button"><a class="toolbar" onClick="javascript:if(document.adminForm.boxchecked.value==0){alert('Please select a User from the list to Unpublish');}else{if(confirm('Are you sure you want to Unpublish the listed Items?')){submitbutton('unpublished');}}" href="javascript:void(0);"> <span title="Unpublish" class="icon-32-unpublish"> </span> Unpublish </a></td>
            <td id="toolbar-publish" class="button"><a class="toolbar" onClick="javascript:if(document.adminForm.boxchecked.value==0){alert('Please select a User from the list to Publish');}else{if(confirm('Are you sure you want to Publish the listed Items?')){submitbutton('published');}}" href="javascript:void(0);"> <span title="Publish" class="icon-32-publish"> </span> Publish </a></td>
            <td id="toolbar-delete" class="button"><a class="toolbar" onClick="javascript:if(document.adminForm.boxchecked.value==0){alert('Please select a User from the list to delete');}else{if(confirm('Are you sure you want to delete the listed Items?')){submitbutton('remove');}}" href="javascript:void(0);"> <span title="Delete" class="icon-32-delete"> </span> Delete </a></td>
            <td id="toolbar-edit" class="button"><a class="toolbar" onClick="javascript:if(document.adminForm.boxchecked.value==0){alert('Please select a User from the list to edit');}else{ hideMainMenu(); submitbutton('edit')}" href="javascript:void(0);"> <span title="Edit" class="icon-32-edit"> </span> Edit </a></td>
            <td id="toolbar-new" class="button"><a class="toolbar" onClick="submitbutton('add')" href="javascript:void(0);"> <span title="New" class="icon-32-new"> </span> New </a></td>
          </tr>
        </tbody>
      </table>
    </div>
    <div class="header icon-48-user">Danh sách Quyền</div>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<?php echo $this->Session->flash('msg'); ?>
<div id="submenu-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <ul id="submenu">
      <li> <a href="<?php echo $this->Html->url(array('controller'=>'users', 'action'=>'index')); ?>">Danh sách user</a> </li>
      <li> <a href="<?php echo $this->Html->url(array('controller'=>'user_groups', 'action'=>'index')); ?>">Nhóm thành viên</a> </li>
       <li> <a href="<?php echo $this->Html->url(array('controller'=>'user_actions', 'action'=>'index')); ?>">Roles</a> </li>
       <li> <a class="active" href="<?php echo $this->Html->url(array('controller'=>'user_permissions', 'action'=>'index')); ?>">Roles</a> </li>
    </ul>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
<div id="element-box">
  <div class="t">
    <div class="t">
      <div class="t"></div>
    </div>
  </div>
  <div class="m">
    <form action="<?php echo $this->Html->url(array('controller'=>'user_permissions')); ?>" method="post" name="adminForm">
      <table>
        <tr>
          <td width="100%"><input type="text" name="search" id="search" class="text_area" value="<?php echo $this->SEARCH_KEYWORD;?>"/>
            <button onClick="document.adminForm.limitstart.value=0; document.adminForm.submit();">Go</button>
            <button onClick="document.adminForm.limitstart.value=0; document.adminForm.search.value=''; document.adminForm.submit();">Clear</button></td>
        </tr>
      </table>
      <table class="adminlist">
        <thead>
          <tr>
            <th width="5%"> Num </th>
            <th width="5%"> <input type="checkbox" name="toggle" value=""  onclick="checkAll(<?php echo $total;?>);" />
            </th>
            <th class="title"> <?php echo $this->Paginator->sort('Usergroup.title', 'Group title'); ?> </th>
            <th class="title"> <?php echo $this->Paginator->sort('Useraction.title', 'Action title'); ?> </th>
            <th><?php echo $this->Paginator->sort('id', 'ID'); ?></th>
          </tr>
        </thead>
        <tfoot>
          <tr>
            <td colspan="8"><?php echo $this->element('paging', array('paging'=>$this->Paginator));?></td>
          </tr>
        </tfoot>
        <tbody>
          <?php
				$tr_class = 0;
                                $i = ($start_page - 1) * $limit_page;
				if($total)
				{
					foreach ($data as $row)
					{
                                            $tr_class = 1 - $tr_class;
				?>
          <tr class="row<?php echo $tr_class;?>">
            <td align="center"><?php echo $i + 1;?></td>
            <td align="center">
                <input id="cb<?php echo $i; ?>" onclick="isChecked(this.checked);" type="checkbox" name="cid[]" value="<?php echo $row['Permission']['id']; ?>" />
            </td>
            <td><?php echo $this->Html->link($row['Usergroup']['title'], array('action'=>'edit','id'=> $row['Usergroup']['id'])); ?></td>
            <td><?php echo $row['Useraction']['title']; ?></td>

         <td align="center"><?php echo $row['Permission']['id'];?></td>
          </tr>
          <?php
                                    $i++;
					}
				}
				else
				{
				?>
          <tr>
            <td align="center" colspan="8"> No contents </td>
          </tr>
          <?php
				}
				?>
        </tbody>
      </table>
      <input type="hidden" name="task" value="index" />
      <input type="hidden" name="boxchecked" value="0" />
      <?php echo $this->FORM_TOKEN;?>
    </form>
    <div class="clr"></div>
  </div>
  <div class="b">
    <div class="b">
      <div class="b"></div>
    </div>
  </div>
</div>
